import sys
from multiprocessing import Process

from simultion import SIMULATION

if __name__ == "__main__":
    
    if len(sys.argv) == 4:
        task = sys.argv[1]
        individual_num = int(sys.argv[2])
        generations = int(sys.argv[3])
    elif len(sys.argv) == 1:
        task = "locomotion"
        individual_num = 1
        generations = 1
        
    else:
        print("参数错误")
        exit()
    
    simulations = []
    processions = []
    
    for i in range(individual_num):
        
        simulations.append(SIMULATION(i))
        processions.append(Process(target=simulations[i].train, args=(generations,task)))
        processions[i].start()
    
    for procession in processions:
        procession.join()
